package com.zyk.java8;

import java.util.Arrays;

/**
 * @author zhangsan
 * @date 2021/5/11 9:05
 */
public class MaximumIncrementSubSequenceInNoSortArray {


    public static int maximunIncrNum(int[] nums) {
        if (nums == null || nums.length == 0) return 0;
        Arrays.sort(nums);
        int N = nums.length, max = 1, cMax = 1, pre = nums[0];
        for (int i = 1; i < N; i++) {
            if (nums[i] == pre) {
                continue;
            } else if (nums[i] == pre + 1) {
                cMax++;
            } else {
                max = Math.max(max, cMax);
                cMax = 1;
            }
            pre = nums[i];
        }
        max = Math.max(max, cMax);
        return max;
    }


    // for test
    public static void main(String[] args) {

    }

}
